namespace WeWorkApp.Api.Models.WeChat
{
    /// <summary>
    /// 企业微信回调事件基础模型
    /// </summary>
    public class CallbackEventDto
    {
        /// <summary>
        /// 第三方应用的SuiteId
        /// </summary>
        public string SuiteId { get; set; } = string.Empty;

        /// <summary>
        /// 授权方的corpid
        /// </summary>
        public string AuthCorpId { get; set; } = string.Empty;

        /// <summary>
        /// 事件类型
        /// </summary>
        public string InfoType { get; set; } = string.Empty;

        /// <summary>
        /// 时间戳
        /// </summary>
        public long TimeStamp { get; set; }
    }

    /// <summary>
    /// suite_ticket推送事件
    /// </summary>
    public class SuiteTicketEventDto : CallbackEventDto
    {
        /// <summary>
        /// Ticket内容，最长为512字节
        /// </summary>
        public string SuiteTicket { get; set; } = string.Empty;
    }

    /// <summary>
    /// 授权成功通知事件
    /// </summary>
    public class CreateAuthEventDto : CallbackEventDto
    {
        /// <summary>
        /// 授权的auth_code
        /// </summary>
        public string AuthCode { get; set; } = string.Empty;
    }

    /// <summary>
    /// 授权变更通知事件
    /// </summary>
    public class ChangeAuthEventDto : CallbackEventDto
    {
        /// <summary>
        /// 授权的auth_code
        /// </summary>
        public string AuthCode { get; set; } = string.Empty;
    }

    /// <summary>
    /// 授权取消通知事件
    /// </summary>
    public class CancelAuthEventDto : CallbackEventDto
    {
        // 基础字段已在父类中定义
    }

    /// <summary>
    /// 通讯录变更事件
    /// </summary>
    public class ChangeContactEventDto : CallbackEventDto
    {
        /// <summary>
        /// 变更类型：create_user, update_user, delete_user, create_party, update_party, delete_party
        /// </summary>
        public string ChangeType { get; set; } = string.Empty;

        /// <summary>
        /// 成员UserID（当变更类型为用户相关时）
        /// </summary>
        public string UserId { get; set; } = string.Empty;

        /// <summary>
        /// 部门ID（当变更类型为部门相关时）
        /// </summary>
        public string PartyId { get; set; } = string.Empty;

        /// <summary>
        /// 标签ID（当变更类型为标签相关时）
        /// </summary>
        public string TagId { get; set; } = string.Empty;
    }

    /// <summary>
    /// 客户联系事件
    /// </summary>
    public class ChangeExternalContactEventDto : CallbackEventDto
    {
        /// <summary>
        /// 变更类型：add_external_contact, edit_external_contact, del_external_contact, del_follow_user
        /// </summary>
        public string ChangeType { get; set; } = string.Empty;

        /// <summary>
        /// 企业成员的UserID
        /// </summary>
        public string UserId { get; set; } = string.Empty;

        /// <summary>
        /// 外部联系人的userid，注意不是企业成员的帐号
        /// </summary>
        public string ExternalUserId { get; set; } = string.Empty;

        /// <summary>
        /// 添加此用户的「联系我」方式配置的state参数，可用于区分添加此外部联系人的渠道
        /// </summary>
        public string State { get; set; } = string.Empty;

        /// <summary>
        /// 欢迎语code，可用于发送欢迎语
        /// </summary>
        public string WelcomeCode { get; set; } = string.Empty;
    }

    /// <summary>
    /// 客户群变更事件
    /// </summary>
    public class ChangeExternalChatEventDto : CallbackEventDto
    {
        /// <summary>
        /// 变更类型：create, update, dismiss
        /// </summary>
        public string ChangeType { get; set; } = string.Empty;

        /// <summary>
        /// 群聊id
        /// </summary>
        public string ChatId { get; set; } = string.Empty;

        /// <summary>
        /// 群主id
        /// </summary>
        public string Owner { get; set; } = string.Empty;

        /// <summary>
        /// 当是成员入群时，表示成员的userid列表
        /// </summary>
        public List<string> JoinScene { get; set; } = new List<string>();

        /// <summary>
        /// 当是成员退群时，表示成员的userid列表
        /// </summary>
        public List<string> QuitScene { get; set; } = new List<string>();

        /// <summary>
        /// 当群名变更时，此字段返回变更后的群名
        /// </summary>
        public string UpdateDetail { get; set; } = string.Empty;
    }
}